package com.dd.stack.rpc.dubbo.consumer.controller;

import com.dd.stack.common.util.Result;
import com.dd.stack.common.util.ResultEnum;
import com.dd.stack.common.util.annotation.ServiceDescription;
import com.dd.stack.common.util.response.ApiResponse;
import com.dd.stack.rpc.dubbo.api.DataObjectApi;
import com.dd.stack.rpc.dubbo.common.pijo.DataObjectRpcBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/3/8 10:11
 * @Description DubboConsumerController
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/consumer")
@Api(tags = "DubboConsumerController")
public class DubboConsumerController {

    @ServiceDescription("dd-stack-ms-provider-Dubbo服务")
    private final DataObjectApi dataObjectApi;

    @GetMapping("/{id}")
    @ApiOperation("通过id获取DataObjectDO对象")
    public ApiResponse<DataObjectRpcBO> get(@ApiParam("DataObjectDO-id") @PathVariable Long id){
        log.info("C DubboConsumerController M get() id = {}", id);
        ApiResponse<DataObjectRpcBO> result = dataObjectApi.getOneById(id);
        log.info("C DubboConsumerController M get() result = {}", result);
        return result;
    }
}
